<template>
  <component
    :is="comp"
    :formData="formData"
    ref="compModel"
    v-if="comp">
  </component>
</template>
<script>
  export default {
    name: 'DynamicNotice',
    data () {
      return {
        compName: this.path
      }
    },
    computed: {
      comp: function () {
        if(!this.path){
          return null;
        }
        const allowedPaths = [
          'system/modules/UserCenterModal',
          'system/modules/UserNoticeModal'
        ];
        
        if (allowedPaths.includes(this.path)) {
          return () => import(`@/views/${this.path}.vue`);
        } else {
          console.warn(`Path not allowed: ${this.path}`);
          return null;
        }
      }
    },
    props: ['path','formData'],
    methods: {
      detail () {
        setTimeout(() => {
          if(this.path && this.$refs.compModel){
            this.$refs.compModel.view(this.formData);
          }
        }, 200)
      },
    }
  }
</script>